﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Configuration;
using DropBoxClient.Entities;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;

namespace DropBoxClient.Tests
{
    [TestClass]
    public class GetThumbnailsTest
    {
        private string accessToken;
        private OAuth2Client client;
        private ImageContent imageContent;

        public TestContext TestContext { get; set; }

        [TestInitialize]
        public void Init()
        {
            accessToken = ConfigurationManager.AppSettings["AccessToken"];
            client = new OAuth2Client(accessToken);
            imageContent = client.GetThumbnails(StringConstants.SandboxRoot, "Test/Image.png");
        }

        [TestMethod]
        public void GetThumbnails_ResultIsNotNull()
        {
            Assert.IsNotNull(imageContent);
        }

        [TestMethod]
        public void GetThumbnails_HasMeta()
        {
            Assert.IsNotNull(imageContent.Meta);
        }

        [TestMethod]
        public void GetThumbnails_VerifyFile()
        {
            var imagePath = Path.Combine(TestContext.TestRunResultsDirectory, "Image.png");
            imageContent.Image.Save(imagePath, ImageFormat.Png);
            Assert.IsTrue(File.Exists(imagePath));
            File.Delete(imagePath);
        }
    }
}
